********************************************************************************
*The ABCs of Covid-19 Prevention in Malawi:
*Authority, Benefits, and Costs of Compliance

*Forthcoming in World Development

*Authors: Kristen Kao, Ellen Lust, Boniface Dulani, , Karen Ferree, Adam Harris, 
*and Erica Metheney 
* 
*Dataset citation: Lust, Ellen (PI); Dulani, Boniface; Harris, Adam; Ferree, 
*Karen; Kao, Kristen; Metheney, Erica. 2020. The GLD-IPOR Covid-19 Survey in 
*Malawi. www.gld.gu.se
*                                                                              *
*                                                                              *
*                          FILE: Data Cleaning.                                *
*                             DATE: 2020-08-10                                 *
*                       DO-FILE AUTHOR: Cecilia Ahsan Jansson  
*
*  SEND QUESTIONS TO: Kristen Kao at kristen.kao@gu.se (Corresponding author) 
*					 or GLD at contact@gld.gu.se
*                                                                              *
********************************************************************************

*----------------------------------SETUP---------------------------------------*

*Set Working Directory
cd "YOUR-FILE-PATH-HERE"

*Import raw data
 use "AuthorityComplianceExperiment_Covid_rawData.dta"
 

*----------------------------------CLEANING------------------------------------*

*-----------------------------------------------------------TREATMENT ATTRIBUTES

*Covid Prevalence 
encode Q_69, gen(CovidPrevalence)

label define attribute1 1 "A few people in your area" 2 "Many people in your area" 3 "No one in your area"
label value CovidPrevalence attribute1

*Authority
encode Q_70, gen(Authority)

label define attribute2 1 "The head of your district hospital" 2 "Your traditional authority" 3 "Your religious authority"
label value Authority attribute2

*Action
encode Q_71, gen(Action)

label define attribute3 1 "Do not gather in groups" 2 "Frequently wash hands" 3 "Stay home except for essentials"
label value Action attribute3

*------------------------------------------------------------DEPENDENT VARIABLES

*Clean and re-code excluding "Don't Know/Refuse to Answer"

label define YesNo 0 "No" 1 "Yes"

gen Comply= 0 if Q_73!= "" & Q_73!= "Don't Know/Refuse to Answer"
replace Comply= 1 if Q_73== "Yes"
label value Comply YesNo

gen OthersComply= 0 if Q_74!= "" & Q_74!= "Don't Know/Refuse to Answer"
replace OthersComply= 1 if Q_74== "Most"

gen HasRight= 0 if Q_75!= "" & Q_75!= "Don't Know/Refuse to Answer"
replace HasRight= 1 if Q_75== "Yes"
label value HasRight YesNo

gen LessenRisk= 0 if Q_76!= "" & Q_76!= "Don't Know/Refuse to Answer"
replace LessenRisk= 1 if Q_76== "Yes"
label value LessenRisk YesNo

gen WillMonitor= 0 if Q_77!= "" & Q_77!= "Don't Know/Refuse to Answer"
replace WillMonitor= 1 if Q_77== "Yes"
label value WillMonitor YesNo

*-----------------------------------------------------RESPONDENT CHARACTERISTICS

*Clean and re-code excluding "Don't Know/Refuse to Answer"

*Ethnicity
encode Q_33, gen(RespondentEthnicity)
replace RespondentEthnicity= . if RespondentEthnicity==3

*Gender
encode Q_22, gen(gender)
gen RespondentGender= 0 if gender==3
replace RespondentGender= 1 if gender== 2
label define RespondentGender 0 "Male" 1 "Female"
label value RespondentGender RespondentGender

*Age
replace Q_23= . if Q_23==999
gen Age= "18-34" if Q_23!=.
replace Age= "35-54" if Q_23>34 & Q_23<55
replace Age= "55-Inf" if Q_23>54
encode Age, gen(RespondentAge)

*Education
encode Q_24, gen(education)
gen RespondentEducation= 1 if (education==1 | education==3) & education!=7 
replace RespondentEducation= 2 if (education==10 | education==6)
replace RespondentEducation= 3 if (education==2 | education==8)
replace RespondentEducation= 4 if (education==11 | education==9| education==5 | education==4)

label define RespondentEducation 1 "Little to No Schooling" 2 "Primary Schooling" 3 "Secondary Schooling" 4 "Post Secondary Schooling"
label value RespondentEducation RespondentEducation

*District
encode Q_25, gen(RespondentDistrict)

*Region
gen Region = ""

replace Region = "Northern" if (RespondentDistrict == 5 | RespondentDistrict == 9 | RespondentDistrict == 11 | RespondentDistrict == 18 | RespondentDistrict == 19| RespondentDistrict == 25)
replace Region = "Central" if (RespondentDistrict == 6 | RespondentDistrict == 8 | RespondentDistrict == 10 | RespondentDistrict == 12 | RespondentDistrict == 15 | RespondentDistrict == 20 | RespondentDistrict == 22 | RespondentDistrict == 23 | RespondentDistrict == 26)
replace Region = "Southern" if (RespondentDistrict == 1| RespondentDistrict == 2| RespondentDistrict == 3| RespondentDistrict == 4| RespondentDistrict == 13| RespondentDistrict == 14| RespondentDistrict == 16| RespondentDistrict == 17|  RespondentDistrict == 21| RespondentDistrict == 24| RespondentDistrict == 27| RespondentDistrict == 28)
replace Region = "Don't Know" if RespondentDistrict == 7

encode Region, gen(RespondentRegion)

*-----------------------------------------------SUPPLEMENTAL, OBSERVATIONAL DATA

*TRUST IN AUTHORITIES: GOVERNMENT

generate Trust_Government= 1 if T_Q_93_1== "Not at all"
replace Trust_Government= 2 if T_Q_93_1=="Just a little"
replace Trust_Government= 3 if T_Q_93_1=="Somewhat"
replace Trust_Government= 4 if T_Q_93_1=="A lot"
replace Trust_Government= 5 if T_Q_93_1=="Haven't heard enough to say."
replace Trust_Government= 6 if T_Q_93_1=="Refuse to Answer"

label define Trust_Government 1 "Not at all" 2 "Just a little" 3 "Somewhat" 4 "A lot" 5 "Haven't heard enough to say" 6 "Refuse to answer"

label value Trust_Government Trust_Government

*TRUST IN AUTHORITIES: OPPOSITION

generate Trust_Opposition= 1 if T_Q_93_3== "Not at all"
replace Trust_Opposition= 2 if T_Q_93_3=="Just a little"
replace Trust_Opposition= 3 if T_Q_93_3=="Somewhat"
replace Trust_Opposition= 4 if T_Q_93_3=="A lot"
replace Trust_Opposition= 5 if T_Q_93_3=="Haven't heard enough to say."
replace Trust_Opposition= 6 if T_Q_93_3=="Refuse to Answer"

label define Trust_Opposition 1 "Not at all" 2 "Just a little" 3 "Somewhat" 4 "A lot" 5 "Haven't heard enough to say" 6 "Refuse to answer"

label value Trust_Opposition Trust_Opposition

*TRUST IN AUTHORITIES: SPECIAL COVID COMMITTEE

generate Trust_SpecCovidCom= 1 if T_Q_93_6== "Not at all"
replace Trust_SpecCovidCom= 2 if T_Q_93_6=="Just a little"
replace Trust_SpecCovidCom= 3 if T_Q_93_6=="Somewhat"
replace Trust_SpecCovidCom= 4 if T_Q_93_6=="A lot"
replace Trust_SpecCovidCom= 5 if T_Q_93_6=="Haven't heard enough to say."
replace Trust_SpecCovidCom= 6 if T_Q_93_6=="Refuse to Answer"

label define Trust_SpecCovidCom 1 "Not at all" 2 "Just a little" 3 "Somewhat" 4 "A lot" 5 "Haven't heard enough to say" 6 "Refuse to answer"

label value Trust_SpecCovidCom Trust_SpecCovidCom

*TRUST IN AUTHORITIES: HOSPITAL HEAD

generate Trust_HospitalHead= 1 if T_Q_93_7== "Not at all"
replace Trust_HospitalHead= 2 if T_Q_93_7=="Just a little"
replace Trust_HospitalHead= 3 if T_Q_93_7=="Somewhat"
replace Trust_HospitalHead= 4 if T_Q_93_7=="A lot"
replace Trust_HospitalHead= 5 if T_Q_93_7=="Haven't heard enough to say."
replace Trust_HospitalHead= 6 if T_Q_93_7=="Refuse to Answer"

label define Trust_HospitalHead 1 "Not at all" 2 "Just a little" 3 "Somewhat" 4 "A lot" 5 "Haven't heard enough to say" 6 "Refuse to answer"

label value Trust_HospitalHead Trust_HospitalHead

*TRUST IN AUTHORITIES: RELIGIOUS LEADER

generate Trust_ReligiousLeader= 1 if T_Q_93_8== "Not at all"
replace Trust_ReligiousLeader= 2 if T_Q_93_8=="Just a little"
replace Trust_ReligiousLeader= 3 if T_Q_93_8=="Somewhat"
replace Trust_ReligiousLeader= 4 if T_Q_93_8=="A lot"
replace Trust_ReligiousLeader= 5 if T_Q_93_8=="Haven't heard enough to say."
replace Trust_ReligiousLeader= 6 if T_Q_93_8=="Refuse to Answer"

label define Trust_ReligiousLeader 1 "Not at all" 2 "Just a little" 3 "Somewhat" 4 "A lot" 5 "Haven't heard enough to say" 6 "Refuse to answer"

label value Trust_ReligiousLeader Trust_ReligiousLeader

*TRUST IN AUTHORITIES: WHO

generate Trust_WHO= 1 if T_Q_93_9=="Not at all"
replace Trust_WHO= 2 if T_Q_93_9=="Just a little"
replace Trust_WHO= 3 if T_Q_93_9=="Somewhat"
replace Trust_WHO= 4 if T_Q_93_9=="A lot"
replace Trust_WHO= 5 if T_Q_93_9=="Haven't heard enough to say."
replace Trust_WHO= 6 if T_Q_93_9=="Refuse to Answer"

label define Trust_WHO 1 "Not at all" 2 "Just a little" 3 "Somewhat" 4 "A lot" 5 "Haven't heard enough to say" 6 "Refuse to answer"

label value Trust_WHO Trust_WHO

*TRUST IN AUTHORITIES: TRADITIONAL AUTHORITY

generate Trust_TA= 1 if T_Q_93_10=="Not at all"
replace Trust_TA= 2 if T_Q_93_10=="Just a little"
replace Trust_TA= 3 if T_Q_93_10=="Somewhat"
replace Trust_TA= 4 if T_Q_93_10=="A lot"
replace Trust_TA= 5 if T_Q_93_10=="Haven't heard enough to say."
replace Trust_TA= 6 if T_Q_93_10=="Refuse to Answer"

label define Trust_TA 1 "Not at all" 2 "Just a little" 3 "Somewhat" 4 "A lot" 5 "Haven't heard enough to say" 6 "Refuse to answer"

label value Trust_TA Trust_TA

*KNOWS COVID BEST: HOSPITAL HEAD

rename A_Q_94_3 KnowsCovid_HospitalHead, replace

label define KnowsCovid_HospitalHead 0 "No" 1 "Yes"
label value KnowsCovid_HospitalHead KnowsCovid_HospitalHead

*KNOWS COVID BEST: RELIGIOUS LEADER

rename A_Q_94_2 KnowsCovid_ReligiousLeader, replace

label define KnowsCovid_ReligiousLeader 0 "No" 1 "Yes"
label value KnowsCovid_ReligiousLeader KnowsCovid_ReligiousLeader

*KNOWS COVID BEST: TRADITIONAL AUTHORITY

rename A_Q_94_1 KnowsCovid_TA, replace

label define KnowsCovid_TA 0 "No" 1 "Yes"
label value KnowsCovid_TA KnowsCovid_TA

*KNOWS COVID BEST: NONE OF THESE

rename A_Q_94_4 KnowsCovid_None, replace

label define KnowsCovid_None 0 "No" 1 "Yes"
label value KnowsCovid_None KnowsCovid_None

*CONFIDENCE IN PUBLIC HEALTH

encode Q_98, gen(Confidence_PublicHealth)

*AGREE WITH LOCK-DOWN

encode Q_99, gen(Agree_Lockdown)

*-------------------------------------------------------------DROP RAW VARIABLES

drop Q_22 Q_23 Q_24 Q_25 Q_33 Q_33_S Q_69 Q_70 Q_71 Q_73 Q_74 Q_75 Q_76 Q_77 T_Q_93_1 T_Q_93_3 T_Q_93_6 T_Q_93_7 T_Q_93_8 T_Q_93_9 T_Q_93_10 Q_98 Q_99 gender education Region

*---------------------------------------------------------EXPORT CLEANED DATASET

save "CleanedData.dta"

